<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>年会抽奖</title>
    <style>
        .wrapper {
            width: 840px;
            height: 420px;
            background: url(./images/bg01.jpg) no-repeat center / cover;
            padding: 100px 300px;
            box-sizing: border-box;
        }
    </style>
</head>

<body>
    <div class="wrapper">
        <strong>精高中科光电科技公司年会抽奖</strong>
        <h2>一等奖：<span id="one">???</span></h1>
            <h2>二等奖：<span id="two">???</span></h3>
                <h2>三等奖：<span id="three">???</span></h5>
    </div>
    <script>

        // 1》声明数组
        const persionArr = ['周杰伦', '刘德华', '周星驰', '梁带丽', '张学友', '成龙', '张柏芝', '郭富城',]

        // 一等奖
        // 2》随机数，数组的下标
        const random1 = Math.floor(Math.random() * persionArr.length)
        // 3》获取元素one，把名字给one
        const one = document.querySelector('#one')
        one.innerHTML = persionArr[random1]
        // 4》每次抽完，删除这个名字
        persionArr.splice(random1, 1)
        // console.log(persionArr);

        // 二等奖
        const random2 = Math.floor(Math.random() * persionArr.length)
        const two = document.querySelector('#two')
        two.innerHTML = persionArr[random2]
        persionArr.splice(random2, 1)

        // 三等奖
        const random3 = Math.floor(Math.random() * persionArr.length)
        const three = document.querySelector('#three')
        three.innerHTML = persionArr[random3]
        persionArr.splice(random3, 1)
    </script>
</body>

</html>